function [position, latency, duration, index] = getState(EEG, statename)
position = [];
latency = [];
index = [];
duration = [];
event = EEG.event;
for i = 1:size(event, 2)
    if(strcmp(event(i).type, statename))
        position = [position event(i).position];
        latency = [latency event(i).latency];
        duration = [duration event(i).duration];
        index = [index i];
    end
end
end

